﻿using Health.Code;
using Health.Domain;
using Health.Infrastructure.Interface;
using Health.WebAPI.Read.Applicant.Command;
using MediatR;

namespace Health.WebAPI.Read.Applicant.CommandHandler
{
    /// <summary>
    /// 显示医生信息
    /// </summary>
    public class DoctorCommandHandler : IRequestHandler<DoctorCommand, APIRestl<List<Doctor>>>
    {
        IBaseRepository<Doctor> doctorRep;

        public DoctorCommandHandler(IBaseRepository<Doctor> doctorRep)
        {
            this.doctorRep = doctorRep;
        }

        public Task<APIRestl<List<Doctor>>> Handle(DoctorCommand request, CancellationToken cancellationToken)
        {
            APIRestl<List<Doctor>> restl = new APIRestl<List<Doctor>>();
            restl.code = APIEnum.显示成功;
            restl.mes = APIEnum.显示成功.ToString();

            var list=doctorRep.GetAll().Where(s=>s.DoctorId==request.DoctorId);

            restl.data = list.ToList();

            return Task.FromResult(restl);
        }
    }
}
